---
description: Hasura Postgres database support
keywords:
  - hasura
  - docs
  - databases
  - postgres
slug: index
toc_max_heading_level: 2
---

import VersionedLink from '@site/src/components/VersionedLink';
import Aiven from '@site/static/img/cloud-dbs/logos/aiven.png';
import Alloy from '@site/static/img/cloud-dbs/logos/alloydb.png';
import Aurora from '@site/static/img/cloud-dbs/logos/aws-aurora.png';
import Azure from '@site/static/img/cloud-dbs/logos/azure.png';
import Cosmos from '@site/static/img/cloud-dbs/logos/cosmos.png';
import RDS from '@site/static/img/cloud-dbs/logos/aws.png';
import RollTide from '@site/static/img/cloud-dbs/logos/crunchy.png';
import DO from '@site/static/img/cloud-dbs/logos/DO.png';
import Elephant from '@site/static/img/cloud-dbs/logos/elephant.png';
import Enterprise from '@site/static/img/cloud-dbs/logos/enterprisedb.png';
import GCP from '@site/static/img/cloud-dbs/logos/gcp.png';
import Postgres from '@site/static/img/databases/logos/postgresql.png';
import Neon from '@site/static/img/cloud-dbs/logos/neon.png';
import PrismaPostgres from '@site/static/img/cloud-dbs/logos/prisma-postgres.png';
import Railway from '@site/static/img/cloud-dbs/logos/railway.png';
import Render from '@site/static/img/cloud-dbs/logos/render.png';
import Supabase from '@site/static/img/cloud-dbs/logos/supabase.png';
import Timescale from '@site/static/img/cloud-dbs/logos/timescaledb.png';
import Yugabyte from '@site/static/img/cloud-dbs/logos/yugabyte.png';

# Postgres & Compatible Databases

## Introduction

Hasura enables connecting to a Postgres and Postgres compatible databases to automatically build an rich GraphQL API
based on the schema.

:::tip Supported Postgres versions

Hasura GraphQL Engine supports all supported versions of Postgres per the
[public documentation](https://www.postgresql.org/support/versioning/).

:::

## Postgres compatible {#postgres-compatible-flavors}

Hasura supports most databases with full Postgres compatibility such as:

<div className="vendor-table">
  <VersionedLink to="/databases/quickstart">
    <div className="card-wrapper">
      <div className="card">
        <img src={Postgres} title="Postgres" alt="Connect Postgres DB to Hasura" />
      </div>
      <h5>Postgres</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/aiven">
    <div className="card-wrapper">
      <div className="card">
        <img src={Aiven} title="Aiven Postgres" alt="Connect Postgres DB to Hasura" />
      </div>
      <h5>Aiven</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/alloy">
    <div className="card-wrapper">
      <div className="card">
        <img src={Alloy} title="Google AlloyDB Postgres" alt="Connect Google AlloyDB to Hasura" />
      </div>
      <h5>AlloyDB</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/aws-aurora">
    <div className="card-wrapper">
      <div className="card">
        <img src={Aurora} title="AWS Aurora Postgres" alt="Connect AWS Aurora Postgres to Hasura" />
      </div>
      <h5>AWS RDS Aurora Postgres</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/aws-postgres">
    <div className="card-wrapper">
      <div className="card">
        <img src={RDS} title="AWS RDS Postgres" alt="Connect AWS RDS Postgres to Hasura" />
      </div>
      <h5>AWS RDS Postgres</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/azure-cosmos">
    <div className="card-wrapper">
      <div className="card">
        <img src={Cosmos} title="Azure Cosmos DB" alt="Connect Azure Cosmos to Hasura" />
      </div>
      <h5>Azure Cosmos</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/azure">
    <div className="card-wrapper">
      <div className="card">
        <img src={Azure} title="Azure Postgres" alt="Connect Azure Postgres to Hasura" />
      </div>
      <h5>Azure Postgres</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/crunchy">
    <div className="card-wrapper">
      <div className="card">
        <img src={RollTide} title="Crunchy Postgres" alt="Connect Crunchy Postgres to Hasura" />
      </div>
      <h5>Crunchy Postgres</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/digital-ocean">
    <div className="card-wrapper">
      <div className="card">
        <img src={DO} title="Digital Ocean Postgres" alt="Connect DO Postgres to Hasura" />
      </div>
      <h5>Digital Ocean Postgres</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/elephant">
    <div className="card-wrapper">
      <div className="card">
        <img src={Elephant} title="ElephantSQL Postgres" alt="Connect ElephantSQL Postgres to Hasura" />
      </div>
      <h5>ElephantSQL</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/enterprisedb">
    <div className="card-wrapper">
      <div className="card">
        <img
          src={Enterprise}
          title="EnterpriseDB BigAnimal Postgres"
          alt="Connect EnterpriseDB BigAnimal Postgres to Hasura"
        />
      </div>
      <h5>EnterpriseDB</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/gcp">
    <div className="card-wrapper">
      <div className="card">
        <img src={GCP} title="Google Cloud SQL Postgres" alt="Connect Google Cloud SQL Postgres to Hasura" />
      </div>
      <h5>Google Cloud SQL Postgres</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/neon">
    <div className="card-wrapper">
      <div className="card">
        <img src={Neon} title="Neon Postgres" alt="Connect Neon Postgres to Hasura" />
      </div>
      <h5>Neon Postgres</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/prisma-postgres">
    <div className="card-wrapper">
      <div className="card">
        <img src={PrismaPostgres} title="Prisma Postgres" alt="Connect Prisma Postgres to Hasura" />
      </div>
      <h5>Prisma Postgres</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/railway">
    <div className="card-wrapper">
      <div className="card">
        <img src={Railway} title="Railway Postgres" alt="Connect Railway Postgres to Hasura" />
      </div>
      <h5>Railway Postgres</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/render">
    <div className="card-wrapper">
      <div className="card">
        <img src={Render} title="Render Postgres" alt="Connect Render Postgres to Hasura" />
      </div>
      <h5>Render Postgres</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/supabase">
    <div className="card-wrapper">
      <div className="card">
        <img src={Supabase} title="Supabase Postgres" alt="Connect Supabase Postgres to Hasura" />
      </div>
      <h5>Supabase Postgres</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/timescale-cloud">
    <div className="card-wrapper">
      <div className="card">
        <img src={Timescale} title="TimescaleDB Postgres" alt="Connect TimescaleDB Postgres to Hasura" />
      </div>
      <h5>TimescaleDB</h5>
    </div>
  </VersionedLink>
  <VersionedLink to="/databases/postgres/yugabyte">
    <div className="card-wrapper">
      <div className="card">
        <img src={Yugabyte} title="YugabyteDB Postgres" alt="Connect YugabyteDB Postgres to Hasura" />
      </div>
      <h5>YugabyteDB</h5>
    </div>
  </VersionedLink>
</div>

:::tip Other Postgres flavors

Curious about any other Postgres flavors? Any other questions? Ask us on
[GitHub discussions](https://github.com/hasura/graphql-engine/discussions)

:::

## Managing data with the Hasura Console

The Hasura Console is a web UI that allows you to manage your data and metadata. It is available at
`http://localhost:8080/console` when you run Hasura locally, or from your project's Console endpoint when you use
[Hasura Cloud](https://cloud.hasura.io).

The data-management features (such as creating tables) are available in the `Data` tab. You can access your GraphQL API
in the `API` tab and interact with it using the GraphiQL interface.

:::info Console support

You can use these tools to manage your PostgreSQL database, but we recommend using your preferred
[PostgreSQL client instead](https://wiki.postgresql.org/wiki/PostgreSQL_Clients). The Hasura Console is designed to be a
tool for managing your GraphQL API, and not a full-fledged database management tool.

:::

## Required user role permissions

Below are the role permissions required for Hasura to perform all its functionality. Note that, with the exception of
`CONNECT` and `GRANT USAGE`, the other features are opt-in, and not enabling them will simply mean that only the
corresponding Hasura features will not work.

- `CONNECT` is required in order for Hasura to connect to your Postgres data source.
- You must `GRANT USAGE` to the Hasura user role for any schema you want to access via Hasura.
- To allow queries and subscriptions via the GraphQL API, `SELECT` permissions are required.
- Similarly, `INSERT`, `UPDATE`, and `DELETE` permissions are required for mutations.
- The Hasura Console requires permissions such as `REFERENCES` and `CREATE` to make changes to your schema.
- `TRIGGER` is required to use [Event Triggers](/event-triggers/overview.mdx)
- If you want to use computed fields or user-defined Postgres functions, the `EXECUTE` permission is required.

## Connecting to Postgres with SSL Authentication {#postgres-ssl-authentication}

Hasura supports SSL-based authentication for connecting to a PostgreSQL database without requiring password
authentication. Below are the steps to configure SSL authentication correctly:

### Step 1. Configure SSL Certificates

Ensure that the required SSL certificates are available and correctly mounted in the Hasura container or pod.

- `SSL_ROOT_CERT`: Path to the root CA certificate (e.g., `/shared-fs/ssl-db/rootCA.crt`)
- `SSL_CERT`: Path to the client certificate (e.g., `/shared-fs/ssl-db/client.crt`)
- `SSL_KEY`: Path to the client private key (e.g., `/shared-fs/ssl-db/client.pem`)

:::info Important

Ensure the private key is in `.pem` format and has the correct permissions:

```sh
chmod 0600 /shared-fs/ssl-db/client.pem
```

:::

### Step 2. Set the Connection String

Use the following format for the `HASURA_GRAPHQL_DATABASE_URL` environment variable:

```sh
HASURA_GRAPHQL_DATABASE_URL="postgresql://<user>@<host>:<port>/<database>?sslmode=verify-ca&sslcert=/path/to/client.crt&sslkey=/path/to/client.pem&sslrootcert=/path/to/rootCA.crt"
```

### Step 3. Verify Connection

Test connectivity using `psql` from inside the Hasura container:

```sh
psql "postgresql://<user>@<host>:<port>/<database>?sslmode=verify-ca&sslcert=/path/to/client.crt&sslkey=/path/to/client.pem&sslrootcert=/path/to/rootCA.crt"
```

If successful, Hasura should now be able to connect using SSL authentication.

### Troubleshooting

If the connection fails, check for:

- Incorrect file permissions (`0600` is required for the private key).
- A mismatched private key format (use `.pem` instead of `.pk8`).
- Logs in the Hasura container (`docker logs <container_id>` or `kubectl logs <pod_name>`).
- PostgreSQL server logs for authentication failures.

## Know more

- [Schema](/schema/postgres/index.mdx)
- [Queries](/queries/postgres/index.mdx)
- [Mutations](/mutations/postgres/index.mdx)
- [Subscriptions](/subscriptions/postgres/index.mdx)
- [Supported Postgres types](/schema/postgres/postgresql-types.mdx)

:::info Note

If you're interested in learning more about PostgreSQL, check out
[this tutorial](https://hasura.io/learn/database/postgresql/introduction/) from our Learn site.

:::
